package tmp;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;

public class ChildProcess {
	public ChildProcess() {
	}

	public static void main(String[] var0) {
	BufferedReader var1 = new BufferedReader(new InputStreamReader(
				System.in));
		while (true) {
			try {
				String var2 = var1.readLine();
				writeFile("ChildProcess received:" + var2);
//				if (var2 == null) {
//					return;
//				}
			} catch (Exception var3) {
				var3.printStackTrace();
			}
		}
	}

	public static void writeFile(String data) {
		try {
			File file = new File("c:\\child.txt");

			// if file doesnt exists, then create it
			if (!file.exists()) {
				file.createNewFile();
			}
			byte[] contentInBytes = data.getBytes();
			FileOutputStream fop = new FileOutputStream(file,true);
			fop.write(contentInBytes);
			fop.flush();
			fop.close();

			System.out.println("Done");

		} catch (IOException e) {
			e.printStackTrace();
		}

	}
}